#!/usr/bin/env python
#coding=utf-8
import os
import sqlite3
class DBConn(object):
    def __init__(self,dbpath="d:\\cndevData.db"):
        self.__DBPath = dbpath
    def ExecSQL(self,sqltext):
        cx = sqlite3.connect(self.__DBPath)
        cx.isolation_level = None
        cx.execute(sqltext)
        cx.commit()  
        cx.close()
    def SelectData(self,sqltext):
        cx = sqlite3.connect(self.__DBPath)
        cu = cx.cursor()
        cu.execute(sqltext)
        _Result = cu.fetchall()
        cu.close()
        cx.close()
        return _Result
    def SelectOne(self,sqltext):
        cx = sqlite3.connect(self.__DBPath)
        cu = cx.cursor()
        cu.execute(sqltext)
        _Result = cu.fetchone()
        cu.close()
        cx.close()
        return _Result
    def ExecSQLWithTrac(self,sqltext):
        self.cx = sqlite3.connect(self.__DBPath,isolation_level = None)
        self.cx.execute(sqltext)
    def Commit(self):
        self.cx.commit()  
        self.cx.close()

        
